package com.feihong.txgw.adapter.product;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.feihong.txgw.R;
import com.feihong.txgw.model.bean.user.HotSearchDataModel;
import com.feihong.txgw.ui.activity.product.HotSearchActivity;

import java.util.List;

/**
 * Created by PVer on 2017/8/3.
 */

public class HotSearchGdAdapter extends BaseAdapter {


    private HotSearchActivity mContext;
    private List<HotSearchDataModel.DataBean> mDatas;

    public HotSearchGdAdapter(List<HotSearchDataModel.DataBean> models, Context mContext ) {
        this.mContext = (HotSearchActivity) mContext;
        this.mDatas = models;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View view, ViewGroup parent) {
        HotCityViewHolder holder;
        if (view == null){
            view = LayoutInflater.from(mContext).inflate(R.layout.item_hot_gridview, parent, false);
            holder = new HotCityViewHolder();
            holder.name = (TextView) view.findViewById(R.id.tv_hotsearch);
            view.setTag(holder);
        }else{
            holder = (HotCityViewHolder) view.getTag();
        }
        holder.name.setText( mDatas.get(position).getSearch());
        return view;
    }
    public static class HotCityViewHolder{
        TextView name;
    }
}
